<?php

namespace App\Models\service;

use App\Models\AdminModel;
use App\Models\base\CurrencyModel;
use App\Models\CustomerModel;
use App\Models\OrderModel;
use App\Models\StaffModel;
use App\Models\TakeOrderModel;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model as BaseModel;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\SoftDeletes;

class CompensateModel extends BaseModel
{
    use HasFactory, SoftDeletes;

    protected $table = 't_service_compensate';

    protected $primaryKey = 'id';

    public $timestamps = true;

    const CREATED_AT = 'created_at';
    
    const UPDATED_AT = null;

    const STATUS = [0 => '待申请', 1 => '待审核', 2 => '待赔偿', 3 => '拒绝赔偿', 4 => '已赔偿'];

    const SOURCE = [1 => '异常件', 2 => '客户', 3 => '后台'];

    protected $guarded = [];

    protected $hidden = [
        'deleted_at',
    ];


    //订单
    public function order(): BelongsTo {
        return $this->belongsTo(OrderModel::class, 'order_id');
    }

    //客户
    public function customer(): BelongsTo {
        return $this->belongsTo(CustomerModel::class, 'customer_id');
    }

    //提单
    public function take_order(): BelongsTo {
        return $this->belongsTo(TakeOrderModel::class, 'take_order_id');
    }

    //赔付人
    public function compensate_admin(): BelongsTo {
        return $this->belongsTo(AdminModel::class, 'compensate_admin_id');
    }

    //申请币种
    public function currency(): BelongsTo {
        return $this->belongsTo(CurrencyModel::class, 'currency_id');
    }

    //实际赔付币种
    public function actual_currency(): BelongsTo {
        return $this->belongsTo(CurrencyModel::class, 'actual_currency_id');
    }



}
